//数正方形
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll n = 0;
	int mod =1e9+7;
	cin >> n;
	n--;
	ll ans = 0;
	for(int i = 1;i<=n;i++)
	{
		ans += i*(n-i+1)*(n-i+1);
		ans%=mod;
	}
	cout<<ans;
	return 0;
}
